/*
 * Parser.h
 *
 *  Created on: 27/08/2013
 *      Author: hijobobo
 */
//#include "List.h"
using namespace std;
#include <fstream>
#include <string>
#include <iostream>
#include <stdio.h>
#include "List.h"
#include <cstring>

#ifndef Parser_H_
#define Parser_H_


class Parser {

	private:

		List<char*>* wordList;
		bool hasNext;
		bool abierto;
		string path;
		ifstream file;

		// Returns the list of words in the current line (internal use).
		List<char*>* getList();

	public:

		// The constructor recieves a filepath for opening a file.
		Parser(string filePath);
		Parser();
		~Parser();

		// Devuelve la siguiente palabra.
		char* nextWord();
		// Devuelve la siguiente palabra.
		void currentLine();

		// Flag for the iterator. Returns false when the file has no more words.
		bool hasNextWord();

		// Opens a new file and sets the file attribute with it.
		void openFile(string pathArgument, ifstream& fileToOpen);

		// Sets a new file to parse. Don't forget to close the old one!
		void setFile(string pathArgument);

		// Use this before setting a new file.
		void closeFile();
};

#endif /* Parser_H_ */
